﻿using System;
using System.Collections.Generic;
using System.Linq;

class NumberCombinations
{
    static void Main(string[] args)
    {
        Console.WriteLine("数字组合问题");
        Console.WriteLine("============");
        Console.WriteLine("数字：1, 2, 3, 4");
        Console.WriteLine("要求：组成互不相同且无重复数字的三位数");
        Console.WriteLine();

        int[] digits = { 1, 2, 3, 4 };
        var combinations = FindCombinations(digits);

        DisplayResults(combinations);
    }

   
    static List<int> FindCombinations(int[] digits)
    {
        var results = new List<int>();

        for (int i = 0; i < digits.Length; i++) 
        {
            for (int j = 0; j < digits.Length; j++) 
            {
                for (int k = 0; k < digits.Length; k++) 
                {
                    if (i != j && i != k && j != k)
                    {
                        int number = digits[i] * 100 + digits[j] * 10 + digits[k];
                        results.Add(number);
                    }
                }
            }
        }

        return results;
    }

    
    static void DisplayResults(List<int> combinations)
    {
        Console.WriteLine($"总共可以组成 {combinations.Count} 个三位数：");
        Console.WriteLine();

       
        for (int i = 0; i < combinations.Count; i++)
        {
            Console.Write($"{combinations[i],4}");
            if ((i + 1) % 10 == 0) 
                Console.WriteLine();
        }

        if (combinations.Count % 10 != 0)
            Console.WriteLine();

        // 统计信息
        Console.WriteLine($"\n 统计信息：");
        Console.WriteLine($"总组合数：{combinations.Count}");
        Console.WriteLine($"最小值：{combinations.Min()}");
        Console.WriteLine($"最大值：{combinations.Max()}");
        Console.WriteLine($"平均值：{combinations.Average():F1}");
    }
}